/*
 * @PageName: 
 * @Description: 
 * @FilePath: /glm-mes-pc/src/api/demandManagement.js
 */
import request from '@/utils/request'
import requestBpmDownload from '@/utils/requestBpmDownload'
import useSettingsStore from '@/store/modules/settings'
const settingsStore = useSettingsStore()

// 需求管理
// 列表
export function getRequireListAPI(data) {
	return request({
		url: '/glm/require/requireList',
		method: 'post',
		data
	})
}

// 提出部门列表
export function selectDeptAPI() {
	return request({
		headers: { repeatSubmit: false },
		url: '/glm/require/selectDept',
		method: 'post'
	})
}

// 承接部门列表
export function selectRealizeDeptAPI() {
	return request({
		url: 'glm/require/selectRealizeDept',
		method: 'post'
	})
}

// 新增需求
export function saveRequireAPI(data) {
	return request({
		url: '/glm/require/saveRequire',
		method: 'post',
		data
	})
}

// 排期/排期变更/撤销/编辑
export function updateRequireAPI(data) {
	return request({
		url: '/glm/require/updateRequire',
		method: 'post',
		data
	})
}

// 查询同部门用户
export function selectWorkerAPI() {
	return request({
		url: '/glm/require/selectWorker',
		method: 'post'
	})
}

// 新增任务/分配任务
export function saveTaskAPI(data) {
	return request({
		url: '/glm/require/saveTask',
		method: 'post',
		data
	})
}

// 表格筛选查询
export function distinctRequireListAPI(params, data) {
	return request({
		url: '/glm/require/distinctRequireList',
		method: 'post',
		params,
		data
	})
}

// 查看需求详情
export function requireDetailAPI(id) {
	return request({
		url: '/glm/require/requireDetail?id=' + id,
		method: 'post'
	})
}

// 获取任务类型
export function getTaskTypeAPI() {
	return request({
		url: '/glm/require/getTaskType',
		method: 'post'
	})
}

// 获取难易程度/工天/人员
export function getComplexityHourPersonAPI(data) {
	return request({
		url: '/glm/require/getComplexityHourPerson',
		method: 'post',
		data
	})
}

// 新-排期保存/排期变更保存 接口
export function requireScheduleAPI(data) {
	return request({
		url: '/glm/require/requireSchedule',
		method: 'post',
		data
	})
}

// 排期变更查询任务列表
export function getTaskListByRequireIdAPI(requireId) {
	return request({
		url: '/glm/require/getTaskListByRequireId?requireId=' + requireId,
		method: 'post'
	})
}

// 任务管理
// 列表
export function getTaskListAPI(data) {
	return request({
		url: '/glm/require/taskList',
		method: 'post',
		data
	})
}

// 查询同部门下的需求列表
export function selectDeptRequireAPI() {
	return request({
		url: '/glm/require/selectDeptRequire',
		method: 'post'
	})
}

// 编辑/开始/完成/撤销
export function updateTaskAPI(data) {
	return request({
		url: '/glm/require/updateTask',
		method: 'post',
		data
	})
}

// 表格筛选查询
export function distinctTaskListAPI(params, data) {
	return request({
		url: '/glm/require/distinctTaskList',
		method: 'post',
		params,
		data
	})
}

// 获取实际工时
export function calculateHourAPI(data) {
	return request({
		url: '/glm/require/calculateHour',
		method: 'post',
		data
	})
}

// 绩效看板
// 项目绩效
export function projectPerformanceAPI(data) {
	return request({
		url: '/glm/require/projectPerformance',
		method: 'post',
		data
	})
}

// 任务绩效
export function taskPerformanceAPI(data) {
	return request({
		url: '/glm/require/taskPerformance',
		method: 'post',
		data
	})
}

// 人员绩效
export function employeePerformanceAPI(data) {
	return request({
		url: '/glm/require/employeePerformance',
		method: 'post',
		data
	})
}

// 获取bpm授权令牌eco-oauth2-token
export const getBPMDownloadEcoOauth2Token = () => {
	return requestBpmDownload({
		url: `/api/oauth2/access-token`,
		method: 'get',
		params: {
			appid: settingsStore.bpmAppid,
			secret: settingsStore.bpmSecret
		}
	})
}

// 任务难易程度占比
export function difficultyRatioAPI(data) {
	return request({
		url: '/glm/require/difficultyRatio',
		method: 'post',
		data
	})
}

// 绩效看板任务明细
export function performanceTaskDetailAPI(data) {
	return request({
		url: '/glm/require/performanceTaskDetail',
		method: 'post',
		data
	})
}

// 绩效看板任务明细 去重
export function distinctPerformanceTaskDetailAPI(params, data) {
	return request({
		url: '/glm/require/distinctPerformanceTaskDetail',
		method: 'post',
		params,
		data
	})
}
// 获取bpm文件地址链接和文件名
export const getBpmFileUrlAndName = (id) => {
	return requestBpmDownload({
		url: `/api/glm/file/get`,
		method: 'get',
		params: {
			id
		}
	})
}

// 导出看板任务列表数据
export function exportRequireExcel(data) {
	return request({
		url: '/glm/require/export',
		method: 'post',
		data,
		responseType: 'blob',
	})
}
